﻿using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Reflection;
using System.Text;

namespace Ruleweaver.Rules.CheckMethods
{
	[ContractClass(typeof(MultiTypeCheckMethodContract))]
	public abstract class MultiTypeCheckMethod : CheckMethod
	{
		protected override bool SupportsTargetType(Type targetType)
		{
			return TargetTypes.Any(supportedType => supportedType.IsAssignableFrom(targetType));
		}

		protected abstract IEnumerable<Type> TargetTypes { get; }
	}

	[ContractClassFor(typeof(MultiTypeCheckMethod))]
	internal abstract class MultiTypeCheckMethodContract : MultiTypeCheckMethod
	{
		protected override IEnumerable<Type> TargetTypes
		{
			get
			{
				Contract.Ensures(Contract.Result<IEnumerable<Type>>() != null);

				return null;
			}
		}
	}
}